#include "videocontroller.h"

VideoController::VideoController(QLabel *label, QObject *parent) : QObject(parent)
{
    imgLbl = label;
    this->threadStream = new ThreadStream(this->imgLbl, this);

    this->threadStream->start();

    record = false;
    play = false;
    this->size = QSize(640, 480);
}

void VideoController::setImgSize(QSize &size)
{
    this->size = size;
    this->threadStream->setImgSize(size);
}

void VideoController::PlayCamera()
{
    this->threadStream->PlayCamera();
}

void VideoController::PlayVideo(QString fileName)
{
    if (fileName.count() > 0)
        this->threadStream->PlayVideo(fileName);
}

bool VideoController::isRecording()
{
    return this->record;
}

bool VideoController::isPlaying()
{
    return this->play;
}

void VideoController::Record()
{
    this->record = record == false ? true : false;
    if (record == true)
        this->threadStream->StartRecording();
    else
        this->threadStream->StopRecording();
}

void VideoController::Stop()
{
    this->play = false;
    this->threadStream->Abort();
}

bool VideoController::Pause()
{
    if (this->threadStream->isPlaying())
    {
        this->threadStream->StopPause();
        return false;
    }
    else
    {
        this->threadStream->Pause();
        return true;
    }
}

void VideoController::Back()
{
}

void VideoController::ReturnTodirect()
{
}

VideoController::~VideoController()
{


}
